package com.example.order.interceptor;

import feign.InvocationContext;
import feign.ResponseInterceptor;
import org.springframework.stereotype.Component;

//@Component
public class XTokenResponseInterceptor implements ResponseInterceptor {
    @Override
    public Object intercept(InvocationContext invocationContext, Chain chain) throws Exception {
        // 获取 Feign 客户端方法的响应
        try {
            Object response = chain.next(invocationContext);
            // 这里可以对接收到的响应进行处理
            System.out.println("Intercepted response: " + response);
            return response;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public ResponseInterceptor andThen(ResponseInterceptor nextInterceptor) {
        return ResponseInterceptor.super.andThen(nextInterceptor);
    }

    @Override
    public Chain apply(Chain chain) {
        return ResponseInterceptor.super.apply(chain);
    }
}
